package Sort;

/**
 * @author Jimmy Zhan WORKSTATION
 * @since 2023/7/12 12:20
 * 说明：
 *      冒泡排序
 */

public class BubbleSort {
    public int[] BubbleSort(int[] nums) {
        if (nums.length == 0 || nums.length == 1) return nums;
        int temp;
        for (int i = 0; i < nums.length - 1; ++i) {
            for (int j = i + 1; j < nums.length; ++j) {
                if (nums[i] > nums[j]) {
                    temp = nums[i];
                    nums[i] = nums[j];
                    nums[j] = temp;
                }
            }
        }
        return nums;
    }
}
